home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 August / SAN CD 8-2007 CD-ROM 27.iso / pc / Media / GlossaryDatabase.swf / scripts / DefineSprite_160 / frame_1 / DoAction.as
Encoding:
Text File  |  2006-05-30  |  2.0 KB  |  89 lines

  1. var iAttachyY = 0;
  2. var iAttachyH = 0;
  3. var oAttachy = null;
  4. var iScrollMax = 0;
  5. var iScrollVal = 0;
  6. var iScrollSmooth = 0;
  7. var iScrollBGH = oScrollBG._height;
  8. var bScrolling = false;
  9. var iOBarHeight = oScrollSlider._height;
  10. var oDummyScroller = new Object();
  11. oScrollSlider._visible = false;
  12. oScrollSlider.onPress = function()
  13. {
  14.    bScrolling = true;
  15.    this.startDrag(0,0,-1,0,iScrollBGH - iOBarHeight);
  16. };
  17. oScrollSlider.onRelease = function()
  18. {
  19.    this.stopDrag();
  20.    bScrolling = false;
  21. };
  22. oScrollSlider.onReleaseOutside = function()
  23. {
  24.    this.onRelease();
  25. };
  26. this.onMouseWheel = function(mVal)
  27. {
  28.    var _loc1_ = false;
  29.    if(oScrollSlider._y > 0)
  30.    {
  31.       _loc1_ = true;
  32.    }
  33.    else
  34.    {
  35.       oScrollSlider._y = 0;
  36.       _loc1_ = false;
  37.    }
  38.    if(oScrollSlider._y < iScrollBGH - iOBarHeight)
  39.    {
  40.       _loc1_ = true;
  41.    }
  42.    else
  43.    {
  44.       oScrollSlider._y = iScrollBGH - iOBarHeight;
  45.       _loc1_ = false;
  46.    }
  47.    if(_loc1_)
  48.    {
  49.       oScrollSlider._y -= mVal / 3;
  50.       bScrolling = true;
  51.    }
  52. };
  53. Mouse.addListener(this);
  54. setScrollBar = function(oScrollAttach, iOrig, iMax)
  55. {
  56.    oAttachy = oScrollAttach;
  57.    iScrollMax = iMax;
  58.    iAttachyH = iOrig;
  59.    if(iScrollMax > iAttachyH)
  60.    {
  61.       oScrollSlider._visible = true;
  62.       iOBarHeight = Math.ceil(iScrollBGH / 100 * (iAttachyH / iScrollMax * 100));
  63.       if(iOBarHeight >= 3)
  64.       {
  65.          oScrollSlider._height = iOBarHeight;
  66.       }
  67.       else
  68.       {
  69.          oScrollSlider._height = 3;
  70.       }
  71.    }
  72.    else
  73.    {
  74.       oScrollSlider._visible = false;
  75.    }
  76.    oDummyScroller._y = oScrollSlider._y;
  77. };
  78. this.onEnterFrame = function()
  79. {
  80.    iScrollSmooth = (oDummyScroller._y - oScrollSlider._y) * 0.5;
  81.    if(iScrollMax > iAttachyH)
  82.    {
  83.       oDummyScroller._y -= iScrollSmooth;
  84.       iScrollVal = Math.round(oDummyScroller._y / (iScrollBGH - iOBarHeight) * 100);
  85.       oAttachy._y = iAttachyY - (iScrollMax - iAttachyH) / 100 * iScrollVal;
  86.       oAttachy.oMask._y = iAttachyY - oAttachy._y;
  87.    }
  88. };
  89.